
"""
Title: nameUtility.py
Author: Matthew Tanner
Project: Facultimes
This is an Oregon State University project built as a requirement for CS319. 
The project is a collaboration between Matthew Tanner, Arnold Baghomian, and
Joseph Helgeson. 

This is a simple uitility used to scrape all valid instructor names from the
Oregon State Universtity. The name formats in the website vary significantly.
Running this file will produce a text file, 'instructors.txt' containing all
valid names. Names can be chosen from here to construct the userlist contained
in facul-config.xml 
"""

from bs4 import BeautifulSoup
import requests
import string
import sys

f = open("instructorlist.txt", "w")

for letter in string.ascii_uppercase:
	print ".",
	sys.stdout.flush()
	first_letter = letter
	url = "catalog.oregonstate.edu/SOCSearcher.aspx?isa="+first_letter+"%&wks=&chr=abcdeop"

	r = requests.get("http://" + url)
	data = r.text
	soup = BeautifulSoup(data)

	for element in soup.find_all('option'):
		name = element.get_text('value').strip().lower()
		f.write(name + "\n")
f.close()